home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Tools / Win95 Secrets / SETUP.Z / PAGETABL.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-07-19  |  1.5 KB  |  76 lines

  1. ;==================================
  2. ; WIN95UNI - Matt Pietrek 1995
  3. ; FILE: WIN95UNI.C
  4. ;==================================
  5.  
  6. .386
  7. .model small
  8.  
  9. .code
  10.  
  11. public __GetPhysicalAddrFromLinear
  12.  
  13. __GetPhysicalAddrFromLinear proc
  14.     push    ebp
  15.     mov     ebp, esp
  16.  
  17.     mov        eax, [ebp+0Ch]
  18.  
  19.     shr        eax,22
  20.     test    DWORD PTR [0FFBFE000h + eax*4], 1        ;; Verify that the Page
  21.     jz        fail                                    ;; Directory is OK
  22.  
  23.     mov        eax,[ebp+0Ch]
  24.     mov        ebx, eax
  25.     shr        eax,12
  26.     mov        eax, DWORD PTR [0FF800000h + eax * 4]    ;; Get Page Table entry
  27.     test    eax,1                                    ;; is it present?
  28.     jz        fail
  29.  
  30.     and        EAX, 0FFFFF000h            ;; Get physical page
  31.     and        ebx, 000000FFFh            ;; combine with low order 12 bytes of
  32.     or        eax, ebx                ;; the linear address
  33.     jmp        done
  34.  
  35. fail:
  36.     mov        eax, -1
  37.  
  38. done:
  39.     pop     ebp
  40.  
  41.     retf 4        ;; NOTE! This is a 16:32 RETF, since we're in a 32 bit seg
  42. __GetPhysicalAddrFromLinear endp
  43.  
  44. public __GetPageAttributes
  45.  
  46. __GetPageAttributes proc
  47.     push    ebp
  48.     mov     ebp, esp
  49.  
  50.     mov        eax, [ebp+0Ch]
  51.  
  52.     shr        eax,22
  53.     test    DWORD PTR [0FFBFE000h + eax*4], 1        ;; Verify that the Page
  54.     jz        fail                                    ;; Directory is OK
  55.  
  56.     mov        eax,[ebp+0Ch]
  57.     mov        ebx, eax
  58.     shr        eax,12
  59.     mov        eax, DWORD PTR [0FF800000h + eax * 4]    ;; Get Page Table entry
  60.     test    eax,1                                    ;; is it present?
  61.     jz        fail
  62.  
  63.     and        eax, 000000FFFh
  64.     jmp        done
  65.  
  66. fail:
  67.     mov        eax, -1
  68.  
  69. done:
  70.     pop     ebp
  71.  
  72.     retf 4        ;; NOTE! This is a 16:32 RETF, since we're in a 32 bit seg
  73. __GetPageAttributes endp
  74.  
  75. END
  76.